Date: Thu, 04 Jan 90 08:56:05 EST From: KESLER%OUACCVMA.BITNET@cornellc.cit.cornell.edu Subject: SUMMARY: Intro Material for Mac Resources & Programming Date: 4 January 1990, 08:43:49 EST >From: KESLER at OUACCVMA To: INFO-MAC at SUMEX-AIM.STANFORD.EDU Dear Moderators, I'm not sure whether I should have sent this as mail or not, but here goes. The following article is an edited collection of information that I received in answer to my request for details regarding some beginning level info on Macintosh Resources and Programming. At the end of the summary is a *reading list*, of sorts, for those who want to delve deeper. I received a number of requests for this summary so I believe there may be many more out there who could use the info. I suggest, because of its length, that you put it in the archives somewhere instead of inserting it into an issue of the digest. The article is just in standard ASCII. ---------------------------------------------------- SUMMARY: MACINTOSH PROGRAMMING AND RESOURCE PRIMERS ---------------------------------------------------- I want to thank all of you who sent replies to my questions about Introductory materials for Macintosh programing and resources. What follows is a spruced up version of what I received; something between a summary and a straight anthology of replies. Forgive me if I mis-edited or deleted some information you sent to me. It's DANGEROUS to let the novice in the group do the summary, but someone has to stand up for the little people! The impression I got from these replies is that there is stuff out there for everyone -- from those who want (like me) to dabble, and those who want to do this sort of thing professionally, and everyone in between. I have added a reading list to the end of this summary for those who requested it. GREETINGS NETLANDERS! My curiosity has gotten the best of me and, like an increasing number of you, I want to do more than just *use* applications on my MAC -- I want to take them apart, make changes, and maybe even write a few myself! What I need is some sort of primer or introduction to a lot of the terminology that I see posted here. Where does someone familiar with programing in the IBM world begin a trek into MacLand? Here are a few questions for starters: 1) WHAT ARE *RESOURCES* IN MACINTOSH TERMINOLOGY? WHAT DO THEY DO? HOW ARE THEY USED AND MANIPULATED? 2) In reference to many postings to the archives I see the acronym MPW quite a bit. I know it has something to do with programing and languages (is it a language?) but I'm not sure. 3) There are many references to a utility program called ResEdit and other similar programs. Where can I get this program? How much does it cost? Who sells it? 4) In short, where is a good place to begin learning how it all works? I'm especially interested in introductory or beginning materials. -------------------------- RESOURCES -------------------------- you have really opened a can of worms for yourself. Resources: Everything on the Macintosh is a resource. Actually, that isn't entirely true, but close enough. Programs consist of CODE resources that load WIND resources and open windows. They use ALRT & DLOG resources, including DITL resources to create alert boxes, and dialogue boxes. The program is identified to the user with an ICN# resource. *** All Mac files have two parts: a "data fork", which contains data whose format is determined by the application, and a resource fork, which contains stuff whose format is determined by the Mac OS. It can also contain special resources whose format is determined by the application as well. The resource for can be viewed as a tree-structured collection of data. This includes things like CODE (executable programs), WDEFs (window definitions), CDEFs (control definitions), FONTs, and so on. *** Every Macintosh file has a "Data fork" and a "Resource Fork". The data fork is just like a unix file, a sequence of characters. The resource fork is a random access data base. Each resource is identified by a 32 bit type and a 32 bit id number. The resource itself contains an arbitrary piece of data. For example a character string. Many resource types have a special meaning. For example a 'FONT' resource contains a font. Most aspects of the Mac user interface are defined in resources, that can be edited with ResEdit. For example, fonts, menus, window definitions, controls, dialogue icons and lots more. Several resource files can be open at the same time. When a program requests a resource it is found by searching all open resource files. The order is normally (1) The current document's resource file. (2) The current application's resource file. (fork). (3) The system's resource fork. (File). Hence a resource in the system file is always available, unless another resource of the same type and id number is stored in the application or document. *** Resources are a form of virtual memory understood well enough by most programmers for it to be successful, but misunderstood enough to convince analysts and MIS managers that the Mac doesn't have any ability to do the things virtual memory OS's can do. Every Mac file can have a data fork and a resource fork. A resource fork is just like a data fork except that part of it (called the resource map) is meant to be handled only by the resource manager (part of the OS). Also, programmer is supposed to only use the resource manager rather than the file manager to access the resource fork of a file. You use the File Manager to access the data fork of a file. Resources are almost everything on the Macintosh except the data found in in your data files (documents). Resources range >From being executable code, templates for data structures or data for other things like strings. Executable code is actually split up into two or more CODE resources called "segments". Things like code for window definitions (WDEF) are also code resources but aren't called CODE because they're just a bunch of procedures. There's only one set of procedures for all applications to use for drawing a window, it's title bar, close box and zoom box for all the "standard" window types because your System file has a standard WDEF resource. Applications that want to use funny windows or people who want to write INITs that make Mac windows look like NeXT windows can simply patch the standard WDEF resource. Some resources describe data structures and initial values for those structures, as in the case of DLOGs (dialog box window template) and DITLs (dialog item lists - buttons and their locations etc). STR resources are an easy way to store strings that you use often, and since they're resources, a French version of your program could be made simply by modifying the string resources and without recompiling your application. Resources can be purged from memory (by the Memory Manager) when they're not being used. Other resources are PICT (MacDraw picture definitions), ICON and MBAR (menu bar defs). System resources are shareable transparently when you use the resource manager - when you ask for ICON ID=128 and if your app doesn't have it, your app gets back the generic ID=128 ICON resource >From the System. Resources are what let 128K Macs run 300K applications that were more impressive in their day compared to IBM PCs. I'd assert that most programmers today don't know how to effectively use 1 MB of memory, our current standard, which is about to change again. ------------------------------------------------------ MPW / Development Environments / Programming Languages ------------------------------------------------------ MPW stands for Macintosh Programmer's Workshop. It is a very expensive, but highly powerful and expandable development environment for Macintosh programming. You would be much better off to save yourself several hundred dollars and start with THINK C, or THINK Pascal. These two products are incredible, similar to Borland's Turbo products in Clone land. The THINK Products are very high quality, reliable, cheap, and very (*** VERY ***) well supported. They also have the advantage of being very small, and about 20-100 times faster than MPW. They will also do everything that MPW will do. *** MPW stands for Macintosh Programming Workbench (I think). It is sort of a unix like shell that integrates various programming tools. There are many different compilers that run under MPW and let you link code from different languages together into a single program. I have never used it, since I use Think C for programming. *** MPW stands for Macintosh Programming Workshop, and it's a "shell" and text editor. It runs things called "Tools", and people like to pretend MPW is a form of a Unix shell for the Macintosh. Several useful tools include compilers like MPW Pascal, MPW C and CFront (Apple's C++ preprocessor). MPW Shell lets you edit text files usually for compilers, but not always. It permits aliasing, it has a form of "grep", and other things you'd normally find in the Unix environment (Yuk). I'd hate MPW to death if it weren't for an OOP (Object Oriented Programming) tool like MacApp that only works with MPW Pascal. You will find everything unnerving and difficult until you learn the power of true OOP languages and things like MacApp, which I strongly recommend you learn as part of your Macintosh learning process. Once you've started, I suggest you immediately consider an OOP language and an OOP tool like MacApp. You may think it's too soon to start thinking about that, but I have a suspicion that by the time you are adept with the Macintosh, everyone else will be using OOP tools. Don't let anybody convince you otherwise. Apple is using C++ with MacApp for their System 7.0 software, and some of the most powerful software packages are now being written using MacApp. Consider learning Symantec's THINK C Class Library or MacApp as part of your initiation to Macintosh programming. Most adept Mac hackers would shun such a thought, but you won't be able to survive a year from now given the order-of-magnitude increase in turn around time garnered from using OOP languages and tools. MacApp comes with several apps (written in MacApp of course!) that allow you to edit View resources (more complicated than what ResEdit can handle) and browse C++ or Object Pascal source code in a SmallTalk sort of fashion. APDA sells MPW, Pascal, C++ and MacApp. *** Pascal and C are the languages of choice on the Mac. The operating system was written in Pascal so much of the documentation from Apple is in Pascal but there's usually straightforward conversions. System 7.0 will be written in C it is rumored so that will become even more important. MPW is the Macintosh Programmer's Workshop from APDA, the Apple Programmers and Developers Association. It costs about $300 for the basic shell and about $300 for each language additionally. I use Think C from Symantec which retails for about $120, highly recommended. ------------------------ RESEDIT ------------------------ One note I would like to make concerning the info I received about ResEdit: Everyone suggested that ResEdit is available >From the archives, but I have not been able to find it listed. Here is what people had to say about ResEdit... Resources are usually created with Rez, or ResEdit, and stored in the resource fork of the application's file. They can be created on the fly by the program, however. *Warning*: ResEdit will edit any resource, including those that the Macintosh Operating System relies on. Use at your own risk, or face the Bomb! *** ResEdit is a resource editor which can be used to look at and modify things found in the resource fork. It's most often used for things like messing with icons and suchlike. *** ResEdit is for editing Resources. It was written by Apple and probably is available from APDA. It may be available for free, look in the info-mac archives. It also comes with Think C which is how I got it. *** APDA is Apple's development tools distribution channel. They sell ResEdit, but I think Apple also has it for free via FTP to Apple's FTP-able Internet workstation. If you were at CMU, you could get it from one of our AppleShare servers - ask around for a copy, it's "free". *** Resedit is "the" resource editor, and is available from APDA, Aplle Computer, Inc., 20525 Mariani Avenue, M/S 33G, Cupertino, CA 95014-6299. It's $25. -------------------------------------- READING LIST -------------------------------------- Here are some suggestions for reading material gleaned from the messages I received (these are not in any particular order). The reason for this is just about everyone suggested I begin my reading with different books, so I leave the choices up to you. a) There was a fairly nice article in the JUNE 1989 issue of MACUSER on page 153 (I neglected to look at the title when I checked the issue). It was on using ResEdit to modify your desktop (the spacing between icons and the way they are arranged, for instance) which was written at a nice tutorial level and along-the-way explained some things about ResEdit, certain kinds of resources, data forks, and the like. If you don't get a better option, you might give it a look. b) Read Inside Mac, Vol 1, 2, 4, & 5. (just 1 & 2 to start. 4 for Hierarchical File System, List Manager, & 5 for Script Manager, New textEdit, and color support.) c) read Scott Knaster's "How to Write Macintosh Software." d) Subscribe to Mactutor, but don't believe everything you need. e) read the Tech. Notes, available by downloading or from APDA. These, along with examples of code are readily available from these archives. f) Join APDA, the Apple Programmers & Developers Association. Their catalog includes tools and prerelease software available nowhere else. They are $20 a year, and reachable through Apple's Cupertino number. g) Macintosh Revealed (all three volumes). h) Try one of the Microsoft Press books. i) If you just want to program and have a good time, then most of the reputable compilers come with decent examples that are worth studying. That, and the volume of Inside Mac that has the managers you are interested in learning, (such as Vol 1: Quickdraw) are enough to take you a long way. j) Pick up a copy of Kurt Schmucker's "Introduction to Object Oriented Programming on the Macintosh" which describes OOP and the old version of MacApp. k) A book on C programming for the Macintosh which has a fantastic chapter on resources is from Addison-Wesley Publishing, Scott Knaster, Macintosh Programming primer in C. It has some excellent example programs, easy to follow and extensible, and a logical organization. l) "Using the Macintosh Toolbox" w/C by Takatsuka, Huxham, & Burnard. ------------------------------------ THE PANEL OF EXPERTS ------------------------------------ These are the folks who were so helpful to me. I'm sure that if you ask them nicely they may just be able to furnish more specific information if you needed it! JELLIS@BOWDOIN (Until 5/90) David Phillip Oster (Arpa: oster@dewey.soe.berkeley.edu) Joe McMahon ELIOT@cs.umass.EDU Brian Patrick Arnold Jeff Meredith MARGARET GIBBS (GIBBSM@LL.LL.MIT.EDU) ___ _____________________________________________ / __  | University Computing and Learning Services | |_| | | | INFORMATION CENTER | / / | Ohio University, Athens, Ohio | |__| |=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=| __ | BITNET: kesler@ouaccvma | |__| |_____________________________________________| "The above information is not mine, I have only edited the info I was sent to make it a bit more coherent and presentable. Many, many thanks to those who contributed."